package com.imooc.uaa.rest;

import lombok.Data;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

// http://localhost:8080/api/greeting
@RestController
@RequestMapping("/api")
public class UserResource {

    @GetMapping("/greeting")
    public String greeting() {
        return "Hello World!";
    }

    @PostMapping("greeting")
    @ResponseStatus(HttpStatus.CREATED)
    public String makeGreeting(@RequestParam("name") String name, @RequestBody Profile profile) {
        return "Hello " + name + "!" + profile.getGender();
    }

    @PutMapping("/greeting/{name}")
    public String uptGreeting(@PathVariable String name) {
        return "Hello " + name + "!";
    }

    @Data
    static class Profile {
        private String gender;
        private String idNo;
    }

}
